<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>xscanu</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="xscans.html" title="xscans" />
    <link rel="next" href="xtratim.html" title="xtratim" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">xscanu</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="xscans.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="xtratim.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="xscanu"></a>
      <div class="titlepage"></div>
      <a id="IndexXscanu" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">xscanu</span>
        </h2>
        <p>xscanu — 
      Compute the waveform and the wavetable for use in scanned synthesis.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp169174000"></a>
        <h2>Description</h2>
        <p>
      Experimental version of <a class="link" href="scanu.html" title="scanu"><em class="citetitle">scanu</em></a>. Allows much larger matrices and is faster and smaller but removes some (unused?) flexibility.  If liked, it will replace the older opcode as it is syntax compatible but extended.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169176304"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>xscanu</strong></span> init, irate, ifnvel, ifnmass, ifnstif, ifncentr, ifndamp, kmass, \
      kstif, kcentr, kdamp, ileft, iright, kpos, kstrngth, ain, idisp, id</pre>
      </div>
      <div class="refsect1">
        <a id="idp169178480"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>init</em></span> -- the initial position of the masses. If this is a negative number, then the absolute of init signifies the table to use as a hammer shape. If init &gt; 0, the length of it should be the same as the intended mass number, otherwise it can be anything.
    </p>
        <p>
      <span class="emphasis"><em>irate</em></span> -- update rate.
    </p>
        <p>
      <span class="emphasis"><em>ifnvel</em></span> -- the ftable that contains the initial velocity for each mass.  It should have the same size as the intended mass number.
    </p>
        <p>
      <span class="emphasis"><em>ifnmass</em></span> -- ftable that contains the mass of each mass. It should have the same size as the intended mass number.
    </p>
        <p>
      <span class="emphasis"><em>ifnstif</em></span> --  
      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" style="list-style-type: disc; ">
            <li class="listitem">
              <p><span class="emphasis"><em>either</em></span> an ftable that contains the spring stiffness of each connection. It should have the same size as the square of the intended mass number. The data ordering is a row after row dump of the connection matrix of the system.</p>
            </li>
            <li class="listitem">
              <p><span class="emphasis"><em>or</em></span> a string giving the name of a file in the MATRIX format</p>
            </li>
          </ul>
        </div>
        <p>
    </p>
        <p>
      <span class="emphasis"><em>ifncentr</em></span> -- ftable that contains the centering force of each mass. It should have the same size as the intended mass number.
    </p>
        <p>
      <span class="emphasis"><em>ifndamp</em></span> -- the ftable that contains the damping factor of each mass.  It should have the same size as the intended mass number.
    </p>
        <p>
      <span class="emphasis"><em>ileft</em></span> -- If init &lt; 0, the position of the left hammer (ileft = 0 is hit at leftmost, ileft = 1 is hit at rightmost).
    </p>
        <p>
      <span class="emphasis"><em>iright</em></span> -- If init &lt; 0, the position of the right hammer (iright = 0 is hit at leftmost, iright = 1 is hit at rightmost).
    </p>
        <p>
      <span class="emphasis"><em>idisp</em></span> -- If 0, no display of the masses is provided.
    </p>
        <p>
      <span class="emphasis"><em>id</em></span> -- If positive, the ID of the opcode. This will be used to point the scanning opcode to the proper waveform maker. If this value is negative, the absolute of this value is the wavetable on which to write the waveshape. That wavetable can be used later from an other opcode to generate sound. The initial contents of this table will be destroyed.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169192176"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kmass</em></span> -- scales the masses
    </p>
        <p>
      <span class="emphasis"><em>kstif</em></span> -- scales the spring stiffness
    </p>
        <p>
      <span class="emphasis"><em>kcentr</em></span> -- scales the centering force
    </p>
        <p>
      <span class="emphasis"><em>kdamp</em></span> -- scales the damping
    </p>
        <p>
      <span class="emphasis"><em>kpos</em></span> -- position of an active hammer along the string (kpos = 0 is leftmost, kpos = 1 is rightmost). The shape of the hammer is determined by init and the power it pushes with is kstrngth.
    </p>
        <p>
      <span class="emphasis"><em>kstrngth</em></span> -- power that the active hammer uses
    </p>
        <p>
      <span class="emphasis"><em>ain</em></span> -- audio input that adds to the velocity of the masses. Amplitude should not be too great.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169199120"></a>
        <h2>Matrix Format</h2>
        <p>
      The new matrix format is a list of connections, one per line linking point x to point y.   There is no weight given to the link; it is assumed to be unity.  The list is proceeded by the line &lt;MATRIX&gt; and ends with a &lt;/MATRIX&gt; line
    </p>
        <p>
      For example, a circular string of 8 would be coded as

      </p>
        <div class="informalexample">
          <pre class="programlisting">
&lt;MATRIX&gt;
0 1
1 0
1 2
2 1
2 3
3 2
3 4
4 3
4 5
5 4
5 6
6 5
6 7
7 6
0 7
&lt;/MATRIX&gt;
        </pre>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169202416"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the xscanu opcode. It uses the file <a class="ulink" href="examples/xscanu.csd" target="_top"><em class="citetitle">xscanu.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp169204272"></a>
          <p class="title">
            <strong>Example 1057. Example of the xscanu opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac    <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o xscanu.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1
<span class="comment">;the matrices can be found in /manual/examples</span>

<span class="oblock">instr</span> 1	<span class="comment">; Plain scanned syntnesis</span>
	<span class="comment">; Note Also that I am using quadratic interpolation on these.</span>
  a0	<span class="op">=</span>           0
	<span class="opc">xscanu</span>      1, .01, 6, 2, "128,8<span class="op">-</span>gridX", 4, 5, 2, .1, .1, <span class="op">-</span>.01, .1, .5, 0, 0, a0, 0, 0
  a1	<span class="opc">xscans</span>      .5, <span class="opc">cpspch</span>(p4), 333, 0, p6			<span class="comment">; NOTE LEFT RIGHT TRAJECTORY (f333) IS CLEAN!</span>
  a1	<span class="opc">dcblock</span> a1
	<span class="opc">outs</span>        a1, a1
<span class="oblock">endin</span>


<span class="oblock">instr</span> 2	<span class="comment">; Scan synthesis with audio injection and dual scan paths</span>

  a0  <span class="opc">diskin2</span>       "fox.wav",1,0,1	
 <span class="comment">; a0,aa	    ins</span>
  a0	<span class="op">=</span>           a0<span class="op">/</span>.8
	<span class="opc">xscanu</span>      1, .01, 6, 2, "128,8<span class="op">-</span>torusX", 14, 5, 2, .01, .05, <span class="op">-</span>.05, .1, .5, 0, 0, a0, 0, 0
  a1	<span class="opc">xscans</span>      .3, <span class="opc">cpspch</span>(7.00), 333, 0, 2			<span class="comment">; NOTE LEFT RIGHT TRAJECTORY (f333) IS CLEAN!</span>
  a2	<span class="opc">xscans</span>      .3, <span class="opc">cpspch</span>(6.00), 77, 0, 2
  a1	<span class="opc">dcblock</span> a1
  a2	<span class="opc">dcblock</span> a2
	<span class="opc">outs</span>        a1<span class="op">*</span>.5,a2<span class="op">*</span>.1
<span class="oblock">endin</span> 

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="comment">; Initial condition</span>
<span class="comment">;f1 0 16 7 0 8 1 8 0</span>
<span class="stamnt">f</span>1 0 128 7 0 64 1 64 0

<span class="comment">; Masses</span>
<span class="stamnt">f</span>2 0 128 -7 1 128 1

<span class="comment">; Centering force</span>
<span class="stamnt">f</span>4  0 128 -7 0 128 2
<span class="stamnt">f</span>14 0 128 -7 2 64 0 64 2

<span class="comment">; Damping</span>
<span class="stamnt">f</span>5 0 128 -7 1 128 1

<span class="comment">; Initial velocity</span>
<span class="stamnt">f</span>6 0 128 -7 -.0 128 .0

<span class="comment">; Trajectories</span>
<span class="stamnt">f</span>7 0 128 -5 .001 128 128
<span class="stamnt">f</span>77 0 128 -23 "128-spiral-8,16,128,2,1over2"
<span class="stamnt">f</span>777 0 128 -23 "128,8-torusX"

<span class="comment">; Spring matrices</span>
<span class="stamnt">f</span>3 0 128 -23 "128-stringX"
<span class="stamnt">f</span>33 0 128 -23 "128-stringcircularX"
<span class="stamnt">f</span>333  0 128 -23 "128-le<span class="stamnt">f</span>t_rightX"
<span class="stamnt">f</span>3333 0 128 -23 "128,8-torusX"
<span class="stamnt">f</span>33333 0 128 -23 "128,8-cylinderX"
<span class="stamnt">f</span>333333 0 128 -23 "128,8-gridX"

<span class="comment">; Sine</span>
<span class="stamnt">f</span>9 0 1024 10 1

<span class="comment">; Pitch tables</span>
<span class="stamnt">f</span>100 0 1024 -7 +3 128 +3 128 -2 128 -2 128 +0 128 +0 128 -4 128 -4 128 +3
<span class="stamnt">f</span>101 0 1024 -7 -2 128 -2 128 -2 128 -2 128 -5 128 -5 128 -4 128 -4 128 -2
<span class="stamnt">f</span>102 0 1024 -7 +3 128 +3 128 +2 128 +2 128 +0 128 +0 128 +0 128 +0 128 +3
<span class="stamnt">f</span>103 0 1024 -7 +7 128 +7 128 +5 128 +5 128 +3 128 +3 128 +3 128 +3 128 +7 

<span class="comment">; Amplitude tables</span>
<span class="stamnt">f</span>200 0 1024 7 1 128 0 128 0 127 0 1 1 128 0 128 0 127 0 1 1 128 0 127 0 1 1
<span class="stamnt">f</span>201 0 1024 7 0 127 0 1 1 127 0 1 1 128 0 127 0 1 1 127 0 1 1 128 0 127 0 1 1 127 0 1 1
<span class="stamnt">f</span>202 0 1024 7 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 
<span class="stamnt">f</span>203 0 1024 7 1 1024 0
<span class="comment">;;f204 0 1024 7 1 512 0 511 0 1 1</span>

<span class="comment">;-----------------------</span>

<span class="comment">; Note list</span>
<span class="stamnt">i</span>1 0 10 6.00 1  2                               
<span class="stamnt">s</span>
<span class="stamnt">i</span>2 0 15
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
        <p>
      For similar examples, see the documentation on <a class="link" href="scans.html" title="scans"><em class="citetitle">scans</em></a>.
    </p>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169209904"></a>
        <h2>See Also</h2>
        <p>
More information on Scanned Synthesis (as well as several other matrices) is available on the <a class="ulink" href="http://www.csounds.com/scanned/" target="_top"><em class="citetitle">Scanned Synthesis page</em></a> at cSounds.com.
    </p>
        <p> Also an article on these opcodes: <a class="ulink" href="http://www.csounds.com/stevenyi/scanned/yi_scannedSynthesis.html" target="_top"><em class="citetitle">http://www.csounds.com/stevenyi/scanned/yi_scannedSynthesis.html</em></a>  , written by Steven Yi </p>
        <p>
      <a class="link" href="scanu.html" title="scanu"><em class="citetitle">scanu</em></a>,
      <a class="link" href="xscans.html" title="xscans"><em class="citetitle">xscans</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169215728"></a>
        <h2>Credits</h2>
        <p>Written by John ffitch.</p>
        <p>New in version 4.20</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="xscans.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="xtratim.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">xscans </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> xtratim</td>
        </tr>
      </table>
    </div>
  </body>
</html>
